import 'dart:io';

import 'package:safemap/safemap.dart';

class LocationModel {
  LocationModel.fromMap(Map<dynamic, dynamic> map) {
    SafeMap safeMap = SafeMap(map);
    callbackTime = safeMap["callbackTime"].string;
    if (Platform.isAndroid) {
      latitude = safeMap["latitude"].doubleValue.toString();
      longitude = safeMap["longitude"].doubleValue.toString();
      locTime = safeMap["locationTime"].string;
    } else if (Platform.isIOS) {
      locTime = safeMap["locTime"].string;
      latitude = safeMap["latitude"].string;
      longitude = safeMap["longitude"].string;
    }
    bearing = safeMap["bearing"].doubleValue.toString();
    altitude = safeMap["altitude"].doubleValue;
    accuracy = safeMap["accuracy"].string;
    speed = safeMap["speed"].string;
    country = safeMap["country"].string;
    province = safeMap["province"].string;
    city = safeMap["city"].string;
    district = safeMap["district"].string;
    street = safeMap["street"].string;
    streetNumber = safeMap["streetNumber"].string;
    cityCode = safeMap["cityCode"].string;
    adCode = safeMap["adCode"].string;
    address = safeMap["address"].string;
  }

  DateTime? dateTime;

  /// `callbackTime`:回调时间，格式为"yyyy-MM-dd HH:mm:ss"
  String? callbackTime;

  /// `locationTime`:定位时间， 格式为"yyyy-MM-dd HH:mm:ss"
  String? locTime;

  /// `locationType`:  定位类型， 具体类型可以参考https://lbs.amap.com/api/android-location-sdk/guide/utilities/location-type

  /// `latitude`:纬度
  String? latitude;

  /// `longitude`:经度
  String? longitude;

  /// `accuracy`:精确度
  String? accuracy;

  /// `altitude`:海拔, android上只有locationType==1时才会有值
  double? altitude;

  /// `bearing`: 角度，android上只有locationType==1时才会有值
  String? bearing;

  /// `speed`:速度， android上只有locationType==1时才会有值
  String? speed;

  /// `country`: 国家，android上只有通过[AMapLocationOption.needAddress]为true时才有可能返回值
  String? country;

  /// `province`: 省，android上只有通过[AMapLocationOption.needAddress]为true时才有可能返回值
  String? province;

  /// `city`: 城市，android上只有通过[AMapLocationOption.needAddress]为true时才有可能返回值
  String? city;

  /// `district`: 城镇（区），android上只有通过[AMapLocationOption.needAddress]为true时才有可能返回值
  String? district;

  /// `street`: 街道，android上只有通过[AMapLocationOption.needAddress]为true时才有可能返回值
  String? street;

  /// `streetNumber`: 门牌号，android上只有通过[AMapLocationOption.needAddress]为true时才有可能返回值
  String? streetNumber;

  /// `cityCode`: 城市编码，android上只有通过[AMapLocationOption.needAddress]为true时才有可能返回值
  String? cityCode;

  /// `adCode`: 区域编码， android上只有通过[AMapLocationOption.needAddress]为true时才有可能返回值
  String? adCode;

  /// `address`: 地址信息， android上只有通过[AMapLocationOption.needAddress]为true时才有可能返回值
  String? address;

  /// `description`: 位置语义， android上只有通过[AMapLocationOption.needAddress]为true时才有可能返回值
  String? description;

  /// `errorCode`: 错误码，当定位失败时才会返回对应的错误码， 具体错误请参考：https://lbs.amap.com/api/android-location-sdk/guide/utilities/errorcode
  String? errorCode;

  /// `errorInfo`: 错误信息， 当定位失败时才会返回
  String? errorInfo;
}
